-
Notifications
You must be signed in to change notification settings - Fork 99
feat: multi asset hash #1296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: multi asset hash #1296
Conversation
…ths, add tests for motion photo with no movie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Just a few thoughts that we will have to figure out how to address.
/// See <https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_multi_asset_hash> | ||
#[derive(Deserialize, Serialize, Debug, PartialEq)] | ||
pub struct MultiAssetHash { | ||
pub parts: Vec<PartHashMap>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add docs for these fields from the spec.
// Keep track of the size of optional parts. | ||
if part.optional.unwrap_or(false) { | ||
optional_sizes += locator.length; | ||
} | ||
expected_offset += locator.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also verify the byte offsets so that each part's length + byte offset doesn't overlap and also doesn't extend past the end of the file.
claim: &Claim, | ||
asset_handler: Option<&dyn AssetIO>, | ||
) -> Result<()> { | ||
let length = stream_len(reader)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to look into this for other parts of the SDK, there is mixed usage of this and .stream_position()
.
// Read only the specified parts within the larger stream. | ||
reader.seek(std::io::SeekFrom::Start(offset))?; | ||
let buf = reader.read_to_vec(length).map_err(|_| { | ||
Error::C2PAValidation(ASSERTION_MULTI_ASSET_HASH_MISSING_PART.to_string()) | ||
})?; | ||
let mut part_reader = Cursor::new(buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be able to use Read::take
here instead of allocating a vec so we keep it purely streams.
} | ||
|
||
// Extract XMP from bytes. | ||
fn extract_xmp_extensions(seg: &JpegSegment) -> Option<XmpExtension> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work here.
Sorry for the delay and thanks for the feedback @ok-nick ! I'll try to address these over the weekend |
CodSpeed Performance ReportMerging #1296 will not alter performanceComparing Summary
|
Changes in this pull request
Give a narrative description of what has been changed.
Checklist
TO DO
items (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.